#include<stdio.h>
#include<stdlib.h> 
typedef struct fuu {
	int a0;
	struct fuu* zi;
	struct fuu* di;
}fu;
fu* fua(int a, fu* shou);
void fub(int a, fu* shou, fu** aaa);
void fuc(int a, int b, fu* shou);
void fud(fu* shou);
void fue(fu* shou);
int main() {
	fu* shou = NULL;
	shou = fua(1, shou);
	fuc(1, 2, shou);
	fuc(1, 3, shou);
	fuc(1, 4, shou);
	fuc(2, 5, shou);
	fuc(2, 6, shou);
	fud(shou); printf("\n");
	fue(shou);
}
fu* fua(int a, fu* shou) {
	shou = (fu*)malloc(sizeof(fu));
	shou->a0 = a;
	shou->zi = NULL;
	shou->di = NULL;
	return shou;
}
void fub(int a, fu* shou, fu** aaa) {
	if (shou->a0 == a) {
		*aaa = shou;
	}
	if (shou->di != NULL) {
		fub(a, shou->di, aaa);
	}
	if (shou->zi != NULL) {
		fub(a, shou->zi, aaa);
	}
}
void fuc(int a, int b, fu* shou) {
	fu* aaa = NULL;
	fu* bbb = (fu*)malloc(sizeof(fu));
	fub(a, shou, &aaa);
	if (aaa->zi == NULL) {
		bbb->di = NULL;
		bbb->zi = NULL;
		aaa->zi = bbb;
		bbb->a0 = b;
	}
	else {
		bbb->di = NULL;
		bbb->zi = NULL;
		bbb->di = aaa->zi->di;
		aaa->zi->di = bbb;
		bbb->zi = NULL;
		bbb->a0 = b;
	}
}
void fud(fu* shou) {
	printf("%d\t", shou->a0);
	if (shou->zi != NULL) {
		fud(shou->zi);
	}
	if (shou->di != NULL) {
		fud(shou->di);
	}
}
void fue(fu* shou) {
	fu* aaa = shou;
	while (aaa != NULL) {
		printf("%d\t", aaa->a0);
		aaa = aaa->di;
	}printf("\n");
	fue(shou->zi);
}
